package com.bolao;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

import com.Adapter.GroupAdapter;
import com.entidades.Group;

public class GroupsFragment extends Fragment {

	private GridView gridView;
	


	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState)  {
		// Inflate the menu; this adds items to the action bar if it is present.
		View rootView = inflater.inflate(
				R.layout.groups_fragment, container, false);

		gridView = (GridView) rootView.findViewById(R.id.gridViewGroups);
		GroupAdapter groupAdapter = new GroupAdapter(container.getContext(), Group.getGroups());
		
		gridView.setAdapter(groupAdapter);
		gridView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> adapter, View arg1, int position,
					long arg3) {
				MainGrupoActivity.setGroup((Group) adapter.getItemAtPosition(position));
				startActivity(new Intent(getActivity(), MainGrupoActivity.class));
			
			}
		});

		return rootView;
	}

	
}
